<?php require 'common/head.php'; ?>
<?php
    require '../db_connection.php';

    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $name    = $_POST['project_name'];
        $desc    = $_POST['description'];
        $start_d = $_POST['start_date'];
        $end_d   = $_POST['end_date'];
        $status   = $_POST['status'];

        $sql = "INSERT INTO `health_care_projects` (`project_name`, `description`, `start_date`, `end_date`,`status`)
             VALUES ('$name', '$desc', '$start_d', '$end_d', $status)";
        if ($conn->query($sql) === TRUE) {
            echo "<script>alert('添加成功');location.href='zhaomu_list.php';</script>";
        } else {
            echo "<script>alert('添加失败');history.back();</script>";
        }
        $conn->close();
        die();
    }
    
    $conn->close();
?>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加招募</strong></div>
  <div class="body-content">
  <form method="post" class="form-x" action="zhaomu_add.php" style="margin-top:20px;" enctype="multipart/form-data">  
      <div class="form-group">
        <div class="label">
          <label>项目名称</label>
        </div>
        <div class="field">
          <input type="text" class="input" value="" name="project_name" data-validate="required:请输入项目名称" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>开始日期</label>
        </div>
        <div class="field">
          <input type="date" class="input" value="" name="start_date" data-validate="required:请输入开始日期" />
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>结束日期</label>
        </div>
        <div class="field">
          <input type="date" class="input" value="" name="end_date" data-validate="required:请输入结束日期" />
        </div>
      </div>
      <div class="form-group" style="display:flex;align-items:center;">
        <div class="label">
          <label>状态</label>
        </div>
        <div class="field">
            <label>进行中 <input type="radio" value="1" name="status" checked/></label>
            <label>已完成 <input type="radio" value="2" name="status" /></label>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>描述</label>
        </div>
        <div class="field">
          <textarea class="input" name="description" style="height:90px;"></textarea>
        </div>
      </div> 
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main" type="submit"> 提交</button>
          <!-- <button class="button bg-main" type="reset">清除</button> -->
        </div>
      </div>    
    </form>
  </div>
</div>

</body></html>   